package com.bdqn.controller;

import com.bdqn.pojo.SysUser;
import com.bdqn.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * ExampleController
 *
 * @author LILIBO
 * @since 2022-11-30
 */
@Controller
public class ExampleController {

    @Resource
    private UserService userService;

    @GetMapping("/hello/{id}")
    public String hello(Model model, HttpServletRequest request, HttpSession session, @PathVariable("id") Long usrId) {
        System.out.println(11111);
        SysUser sysUser = userService.getById(usrId);
        model.addAttribute("user", sysUser);
        request.setAttribute("usrPassword", sysUser.getUsrPassword());
        session.setAttribute("usrRoleId", sysUser.getUsrRoleId());
        System.out.println(1111);
        return "demo/hello";
    }
}
